package com.weixing.mall.provider.controller.ads;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.dto.ads.MediaTypeDto;
import com.weixing.mall.provider.model.query.MediaTypeQuery;
import com.weixing.mall.provider.service.IMediaTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wx
 * @Date 2019/8/15 15:22
 * @Version 1.0
 */
@RestController
@RequestMapping("mediaType")
@Api(value = "媒体分类Api",tags = "媒体分类")
public class MediaTypeController extends BaseController  {

    @Autowired
    private IMediaTypeService mediaTypeService;

    @GetMapping("")
    @ApiOperation(value = "查询分类")
    public Result list(MediaTypeQuery mediaTypeQuery){
        return ResultUtil.success(mediaTypeService.selectOfPage(initMpPage(),mediaTypeQuery));
    }

    @PostMapping("save")
    @ApiOperation(value = "新增/修改")
    public Result save(MediaTypeDto mediaTypeDto){
        mediaTypeService.save(mediaTypeDto);
        return ResultUtil.success();
    }

    @PostMapping("del/{id}")
    @ApiOperation("删除")
    public Result del(@PathVariable Long id){
        return mediaTypeService.removeById(id) ?ResultUtil.success():ResultUtil.error();
    }

    @PostMapping("queryDetails/{id}")
    @ApiOperation("查询详情")
    public Result queryDetails(@PathVariable Long id){
        return ResultUtil.success(mediaTypeService.queryDetails(id));
    }

    @GetMapping("form")
    @ApiOperation("查询-用于媒体平台 select下拉框")
    public Result form(){
        return ResultUtil.success(mediaTypeService.selectMediaTypeFormVo());
    }
}
